<!-- application\admin\view\kuerp\goods_sales\scoreapply.html -->
<link href="__CDN__/assets/addons/kuerp/css/common.css?v={$Think.config.site.version}" rel="stylesheet">

<style type="text/css">
    .btn-list {
        position: fixed;
        right: 40px;
    }
    .div-flex {
        display: flex
    }
    .div-flex .form-group {
        margin-right: 50px;
        text-align: center;
        line-height: 25px;
        margin-bottom: 0;
    }
    .tab-pane {
        border: 1px solid #F6F6F6;
    }
    .i-color {
        font-size: 34px;
        margin-right: 10px;
        color: #86C3FF;
    }
    .thumbnail {
        display: flow-root;
        width: max-content;
    }
    .thumbnail img {
        width: 50px;
        float: left;
        padding: 5px;
    }
    .text-color {
        color: #777;
    }
    
    .examine_title {
        font-size: 14px;
        color: #333;
        -webkit-box-flex: 1;
        -ms-flex: 1;
        flex: 1;
        display: block;
        height: 30px;
    }
    
    .examine_box {
        padding-left: 20px;
        position: relative;
    }
    
    .examine_box .newicon {
        position: absolute;
        left: 0;
        top: 0;
        z-index: 2;
    }
    
    .examine_box .xian {
        width: 1px;
        height: 100%;
        background: #e6e6e6;
        position: absolute;
        left: 4px;
        top: 10px;
        z-index: 1;
    }
    
    .examine_box .examine_bg {
        position: relative;
        margin-top: 15px;
        border-radius: 4px;
        background-color: #f7f8fa;
        font-size: 12px;
        color: #929293;
        padding: 8px;
        line-height: 18px;
    }
    
    .rowbox {
        display: flex;
        justify-content: flex-start;
        align-items: center;
    }
    
    .stafflist {
        width: 70px;
        text-align: center;
        float: left;
    }
    
    .stafflist-right {
        width: 30px;
        text-align: center;
        float: left;
        margin: 0 20px;
    }
    
    .stafflist-right:last-child {
        display: none;
    }
    
    .stafflist img {
        width: 40px;
        height: 40px;
        margin: 10px;
        border-radius: 50%;
    }
    
    .user-image {
        width: 40px;
        height: 40px;
        border-radius: 50%;
    }
    
    .section-title {
        border-left: 3px solid #2aa1e5;
        padding-left: 10px;
        margin: 20px 0;
        font-weight: bold;
    }
</style>

<div class="panel panel-default panel-intro">
    <input type="hidden" name="ids" id="ids" value="{$ids}"/>
    <div class="div-flex">
        <i class="fa fa-address-card i-color"></i>
        <div style="line-height: 35px">
            <b>{$row.purchase_code}</b>
        </div>
    </div>

    <div style="margin-top: 10px"></div>
    
    <!-- 订单基本信息 -->
    <div class="div-flex" style="margin-top: 20px">
        <div class="form-group">
            <span class="text-muted">订单编号</span>
            <p>{$row.purchase_code}</p>
        </div>

        <div class="form-group">
            <span class="text-muted">客户名称</span>
            <p>{if condition="isset($customer_info.customer_name)"}{$customer_info.customer_name}{/if}</p>
        </div>
        <div class="form-group">
            <span class="text-muted">产品总金额</span>
            <p>{$row.money_tax_price + $row.back_money}</p>
        </div>
        <div class="form-group">
            <span class="text-muted">销售金额</span>
            <p>{$row.all_money}</p>
        </div>
        <div class="form-group">
            <span class="text-muted">返款金额</span>
            <p>{$row.back_money}</p>
        </div>
        <div class="form-group">
            <span class="text-muted">已收款金额</span>
            <p>{$row.pay_money}</p>
        </div>
        <div class="form-group">
            <span class="text-muted">未回款金额</span>
            <p style="color: red">{$row.no_money}</p>
        </div>
        <div class="form-group">
            <span class="text-muted">单据日期</span>
            <p>{$row.purchase_time}</p>
        </div>
        <div class="form-group">
            <span class="text-muted">销售员</span>
            <p>{if condition="isset($row.sale_user_name)"}{$row.sale_user_name}{/if}</p>
        </div>
    </div>
    
    <!-- 产品明细 -->
    <div class="section-title">产品明细</div>
    <div class="well">
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>产品名称</th>
                    <th>锁号</th>
                    <th>购买类型</th>
                    <th>单位</th>
                    <th>数量</th>
                    <th>销售单价(元)</th>
                    <th>返款金额(元)</th>
                    <th>销售金额(元)</th>
                </tr>
            </thead>
            <tbody>
                {foreach name="goods_list" item="goods"}
                <tr>
                    <td>{$goods.goods.goods_name}</td>
                    <td>{$goods.serial}</td>
                    <td>{$goods.goods_type}</td>
                    <td>{$goods.goods_unit}</td>
                    <td>{$goods.number}</td>
                    <td>{$goods.unit_price}</td>
                    <td>{$goods.back_money}</td>
                    <td>{$goods.all_money}</td>
                </tr>
                {/foreach}
            </tbody>
        </table>
    </div>
    
    <!-- 已申请列表 -->
    {if condition="$applyList"}
    <div class="section-title">已申请列表</div>
    <div class="well"> 
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>申请编码</th>
                    <th>申请人</th>
                    <th>申请总积分</th>
                    <th>加赠总积分</th>
                    <th>申请明细</th>
                    <th>申请时间</th>
                    <th>赠送状态</th>
                </tr>
            </thead>
            <tbody>
                {foreach name="applyList" item="apply"}
                <tr>
                    <td>{$apply.apply_code}</td>
                    <td>{$apply.admin.nickname}</td>
                    <td>{$apply.total_score}</td>
                    <td>{$apply.add_score}</td>
                    <td>
                        {foreach name="apply.apply_data" item="apply_data"}
                        {$apply_data.mobile}:{:array_sum([$apply_data.score * 1,$apply_data.addscore ?? 0])}<br>
                        {/foreach}
                    </td>
                    <td>{$apply.createtime}</td>
                    <td>{$apply.pay_status ? '已赠送' : '待赠送'}</td>
                </tr>
                {/foreach}
            </tbody>
        </table>
    </div>
    {/if}
    <!-- 积分申请表单 -->
    <div class="section-title">积分申请</div>
    <form id="scoreapply-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
        <input type="hidden" name="row[purchase_id]" value="{$row.id}">
        
        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">积分申请说明:</label>
            <div class="col-xs-12 col-sm-8">
                <textarea id="c-remark" class="form-control" name="row[remark]" rows="3" placeholder="请输入积分申请说明"></textarea>
            </div>
        </div>
        
        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2">申请明细:</label>
            <div class="col-xs-12 col-sm-8">
                <dl class="fieldlist" data-template="scoreitemtpl" data-name="apply_data">
                    <dd>
                        <ins style="width:20%">手机号</ins>
                        <ins style="width:30%">赠送积分</ins>
                        <ins style="width:30%">备注</ins>
                    </dd>
                    <dd>
                        <a href="javascript:;" class="btn btn-sm btn-success btn-append">
                            <i class="fa fa-plus"></i> 添加
                        </a>
                    </dd>
                    <textarea name="apply_data" class="form-control hide" cols="30" rows="5"></textarea>
                </dl>
                
                <script id="scoreitemtpl" type="text/html">
                <dd class="form-inline">
                    <ins style="width:20%">
                        <input type="text" name="row[<%=name%>][<%=index%>][mobile]" class="form-control" data-rule="required;mobile" placeholder="请输入手机号" value="<%=row.mobile||''%>">
                    </ins>
                    <ins style="width:30%">
                        <input type="number" name="row[<%=name%>][<%=index%>][score]" class="form-control" data-rule="required;range(1~)" placeholder="请输入赠送积分" value="<%=row.score||''%>">
                    </ins>
                    <ins style="width:30%">
                        <input type="text" name="row[<%=name%>][<%=index%>][remark]" class="form-control" placeholder="请输入备注" value="<%=row.remark||''%>">
                    </ins>
                    <span class="btn btn-sm btn-danger btn-remove">
                        <i class="fa fa-times"></i>
                    </span>
                </dd>
                </script>
            </div>
        </div>
        
        <div class="form-group layer-footer">
            <label class="control-label col-xs-12 col-sm-2"></label>
            <div class="col-xs-12 col-sm-8">
                <button type="submit" class="btn btn-primary btn-embossed disabled">提交申请</button>
                <button type="reset" class="btn btn-default btn-embossed">重置</button>
            </div>
        </div>
    </form>
</div>